#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int minChanges(int n, int k) {
        int res = 0;
        while (k != 0 || n != 0)
        {
            if (k % 2 == 0 && n % 2 == 1) ++res;
            if (k % 2 == 1 && n % 2 == 0) return -1;
            k /= 2;
            n /= 2;
        }
        return res;
    }
};